﻿<html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>
            企业进销存系统
        </title>
        <link rel="stylesheet" href="./css/common.css" type="text/css" media="screen"/>
        <script type="text/javascript" src="./js/jquery-1.8.3.min.js"></script> 
    </head>
    
    <body >
        <form id="mpwd">
            <label class="pwdl">旧密码：</label><input type='password' id='oldpwd'/><br>
            <label class="pwdl">新密码：</label><input type='password' id='newpwd'/><br>
            <label class="pwdl">确认新密码：</label><input type='password' id='newpwdagain'/><br>
            <div style="text-align:center;width:250px">
                <div class="button" style="" onclick='clickLog();' >修改密码</div>
                <!--<button type="submit" class="pwdb" id="modifypwd"></button>-->
                <button type="reset" class="pwdb" id="cancelpwd">取消操作</button>
            </div>
        </form>
        
    </body>
<script>
	function clickLog() {
        if($('#oldpwd').val()===""||$('#newpwd').val()===""||$('#newpwdagain').val()===""){
            alert("请填满所有内容");
        }   
        else if($('#newpwdagain').val()===$('#newpwd').val()){
            $.ajax({
                type : "POST",
                url : "/SpringMVC/modifypw.do",
                async:false,
                data:{
                    "userid":_locS['user_id'],
                    "oldpwd":$('#oldpwd').val(),
                    //"account":$('#userid').val(),
                    "newpwd":$('#newpwd').val()
                },
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                dataType : 'json',
                success : function(data) {
                    //alert(data.result);
                    if(data.result===1){
                        alert("旧密码输入错误");
                    }else{
                    	alert("修改成功");
                    }
                    location.href='';
                },
                error : function(data) {
                   alert("error");
                }            
                  
            });

        }else{
            alert("两次输入的新密码不一致");
        }	
	}
</script>

</html>